<?php
/*
	排队
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'liuyan';
if($_RQ['op']=='liuyan'){
	//信息管理
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$fields=array();
	$list=pdo_getslice('core_account_message',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'liuyan','title'=>'信息列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('name'=>'name','title'=>'用户名称','type'=>'string'),
			array('name'=>'mobile','title'=>'用户手机','type'=>'string'),
			array('name'=>'type','title'=>'状态','type'=>'radio','options'=>'types'),
		),
		),
	);
	$return['htmls']=$htmls;
	$return['types']=array(
		'0'=>'用户留言',
		'1'=>'投诉建议',
	);
	
	exi($return);
}
if($_RQ['op']=='tousu'){
	//信息管理
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$fields=array();
	$list=pdo_getslice('core_account_message',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'tousu','title'=>'信息列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'id','title'=>'ID','type'=>'string'),
			array('name'=>'name','title'=>'用户名称','type'=>'string'),
			array('name'=>'mobile','title'=>'用户手机','type'=>'string'),
			array('name'=>'type','title'=>'状态','type'=>'radio','options'=>'types'),
		),
		),
	);
	$return['htmls']=$htmls;
	$return['types']=array(
		'0'=>'用户留言',
		'1'=>'投诉建议',
	);
	
	exi($return);
}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=$this->get('message',array('id'=>$id));

	}else{
		$item=array();
	}
	$return['item']=$item;
	$return['htmls']=array(
			'type' => 'edit',
			'post' => 'post',
			'tabs'=>array(
				array('op'=>'list','title'=>'信息列表'),
			),
			'edits' => array(
				array('title'=>'信息设置','list'=>array(
				array('name'=>'title','title'=>'信息名称','type'=>'string','help'=>'1-2桌,3-4桌,5-6桌,7-10桌'),
				array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
				array('name'=>'num','title'=>'提前通知人数','type'=>'string','help'=>'例如：提前5人发信息通知！'),
				array('name'=>'pre','title'=>'信息编号前缀','type'=>'string','help'=>'例如：A-,B-,C-'),
				array('name'=>'display','title'=>'排序','type'=>'string','help'=>'数字越大排名越靠前！'),
             ),),),
     );
	$return['status']=array(
		'0'=>'启用',
		'1'=>'关闭',
	);
	exi($return);
}

if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('core_account_message',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
  //启用
  if($_RQ['op']=='start'){
	
	$id=intval($_RQ['id']);
	if($id){
		$this->update('message',array('status'=>0),array('id'=>$id));	
	}

	exi('启用成功！');
  }
   if($_RQ['op']=='off'){
	
	$id=intval($_RQ['id']);
	if($id){
		$this->update('message',array('status'=>1),array('id'=>$id));	
	}

	exi('关闭成功！');
  }